<html>
<head><meta charset="utf-8"><title>guards held across await lints · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html">guards held across await lints</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210201970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210201970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210201970">(Sep 15 2020 at 22:56)</a>:</h4>
<p>so there are two lints that have recently been added to clippy, <a href="https://github.com/rust-lang/rust-clippy/pull/6029">https://github.com/rust-lang/rust-clippy/pull/6029</a> and <a href="https://github.com/rust-lang/rust-clippy/pull/5439/files">https://github.com/rust-lang/rust-clippy/pull/5439/files</a> that are currently in the pedantic group</p>



<a name="210201994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210201994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210201994">(Sep 15 2020 at 22:57)</a>:</h4>
<p>im reviewing the newest one and I'm thinking that these lints should probably be in <code>style</code> or maybe even <code>correctness</code></p>



<a name="210202000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210202000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210202000">(Sep 15 2020 at 22:57)</a>:</h4>
<p>what does everyone else think?</p>



<a name="210202045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210202045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210202045">(Sep 15 2020 at 22:57)</a>:</h4>
<p>Its hard to think of a situation where you'd want a suspended future to be holding onto a lock which makes me think correctness is the right category for it</p>



<a name="210218530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210218530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ahmed Charles <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210218530">(Sep 16 2020 at 03:25)</a>:</h4>
<p>Correctness seems right.</p>



<a name="210272113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210272113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210272113">(Sep 16 2020 at 14:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/257328-clippy/topic/guards.20held.20across.20await.20lints/near/210201994">said</a>:</p>
<blockquote>
<p>im reviewing the newest one and I'm thinking that these lints should probably be in <code>style</code> or maybe even <code>correctness</code></p>
</blockquote>
<p>For correctness lints, we should be sure, that there aren't any/many FPs in the lint. If you're under the impression, that this is the case for those lints, we can put them in the correctness group. Since I'm not really familiar with async stuff and didn't review either PR, I trust you to judge if those lints are ready to be deny-by-default.</p>



<a name="210291506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210291506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210291506">(Sep 16 2020 at 17:07)</a>:</h4>
<p>I don't trust myself to judge if the lints are ready for deny-by-default, lol</p>



<a name="210296395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/210296395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#210296395">(Sep 16 2020 at 17:45)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust-clippy/issues/6029">clippy#6029</a> LGTM<br>
<a href="https://github.com/rust-lang/rust-clippy/issues/5439">clippy#5439</a> also LGTM</p>
<p>Side-note: these lints could be moved into the same module IMO.</p>



<a name="211520130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/211520130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Smith <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#211520130">(Sep 28 2020 at 17:03)</a>:</h4>
<p>Would a crater run (new enough to Clippy to not know how hard it is to run a new lint with crater) give us some insight into the FP rate?</p>



<a name="211520281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/211520281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#211520281">(Sep 28 2020 at 17:04)</a>:</h4>
<p>looks like it's available: <a href="https://github.com/rust-lang/crater/blob/master/docs/bot-usage.md#available-experiment-modes">https://github.com/rust-lang/crater/blob/master/docs/bot-usage.md#available-experiment-modes</a></p>



<a name="211521855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/211521855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Smith <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#211521855">(Sep 28 2020 at 17:16)</a>:</h4>
<p>cool. I'll put a similar comment on the PR. my vote would be to merge as pedantic, run the crater run to get an estimate of the false positive rate is on either/both of the lints, and create a separate PR for pedantic -&gt; correctness. among other things, that gives us a nice, easy PR to revert if we find out we're wrong after the fact.</p>



<a name="211526330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/211526330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#211526330">(Sep 28 2020 at 17:53)</a>:</h4>
<p>Since crater runs are expensive, I'm not sure whether we can do a crater run just to find FPs in a lint. We can just make it a correctness lint and wait for the complaints, as we usually do :D</p>



<a name="211526597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/211526597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#211526597">(Sep 28 2020 at 17:55)</a>:</h4>
<p>That's genuinely a better idea.</p>
<p>If it's just a warning, and particularly if it's just in clippy, then put out the lint and let feedback guide further developments.</p>



<a name="211531353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/211531353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Smith <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#211531353">(Sep 28 2020 at 18:34)</a>:</h4>
<p>Makes sense. As long as it is a separate PR that can be reverted to go back to pedantic, that's fine with me.</p>



<a name="217433731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/217433731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Smith <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#217433731">(Nov 20 2020 at 17:34)</a>:</h4>
<p>I did a little bit of looking for a fix of <a href="https://github.com/rust-lang/rust-clippy/issues/6353">https://github.com/rust-lang/rust-clippy/issues/6353</a> and have a failing test case in (draft) <a href="https://github.com/rust-lang/rust-clippy/pull/6355">https://github.com/rust-lang/rust-clippy/pull/6355</a>. I had been optimistic that there was an easy way to access if a variable had been dropped, but I wasn't able to find anything. Would someone have a pointer to help me get started?</p>



<a name="217552648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/217552648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#217552648">(Nov 22 2020 at 14:02)</a>:</h4>
<p>Sorry for the late answer. The <code>GeneratorInteriorTypeCause</code> only tells us if the value _may_ live across a generator yield. The right way to fix this would be to improve the analysis for this to also detect drops of bindings. I have no idea how hard this would be though. Probably quite hard... I'd suggest to just mention this in the Known Problems section for now. Except you want to dive deep into this, but I'm afraid that I couldn't provide much mentoring for this.</p>



<a name="217818785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/guards%20held%20across%20await%20lints/near/217818785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Smith <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/guards.20held.20across.20await.20lints.html#217818785">(Nov 24 2020 at 21:54)</a>:</h4>
<p>Thanks. I'll add the known problem next week. Short term, I don't have the cycles to dive too deep.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>